package org.zy.service.impl;


import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.zy.bean.tresource;
import org.zy.bean.trole;
import org.zy.bean.tuser;
import org.zy.commons.SqlSessionTool;
import org.zy.dao.troleMapper;
import org.zy.dao.tuserMapper;

public class UserServiceTest {

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void test1() {
		tuser user=new  UserService().getUserInfo(2);
		System.out.println(user);
		List<trole> role=user.getRoles();
		for (trole trole : role) {
			System.out.println(trole.getText());
		}
		Assert.assertNotNull(user);
	}
	@Test
	public void test2(){
		
		 SqlSession session = SqlSessionTool.openSession();
		 troleMapper dao = session.getMapper(troleMapper.class);
		 trole user = dao.selectByPrimaryKey(1);
		 List<tresource> resource=user.getTresourece_list();
		 for (tresource tresource : resource) {
			System.out.println(tresource.getTest());
		}
		 SqlSessionTool.closeSession();
		
	}
	@Test
	public void test3(){
		 SqlSession session = SqlSessionTool.openSession();
		 tuserMapper dao = session.getMapper(tuserMapper.class);
		 tuser user = dao.getUserInfoByUsername("admin");
		 
		 List<trole> role=user.getRoles();
			for (trole trole : role) {
				System.out.println(trole.getText());
				System.out.println(trole.getId());
			}
		 SqlSessionTool.closeSession();
		
	}
}
